/*
 * Power.h
 *
 *  Created on: Dec 28, 2008
 *      Author: sez
 */

#ifndef POWER_H_
#define POWER_H_

#include "DndData.h"
#include "TitledData.h"

#include <Xml/XmlPath.h>

#include <QString>
#include <QStringList>

class Power : public TitledData
{
public:
    enum PowerType
    {
        ATTACK_POWER,
        UTILITY_POWER
    };

    static const int NUM_POWER_TYPES = 2;
    static const char *POWER_TYPE_NAMES[];

    enum PowerAvailability
    {
        AT_WILL,
        ENCOUNTER,
        DAILY,
        RECHARGE
    };

    static const int NUM_POWER_AVAILABILITY = 4;
    static const char *POWER_AVAILABILITY_NAMES[];

    enum ActionCost
    {
        NO_ACTION,
        FREE_ACTION,
        IMMEDIATE_INTERRUPT,
        IMMEDIATE_REACTION,
        MINOR_ACTION,
        STANDARD_ACTION,
        MOVE_ACTION
    };

    static const int NUM_ACTION_COSTS = 7;
    static const char *ACTION_COST_NAMES[];

    enum RangeType
    {
        MELEE_RANGE,
        MELEE_WEAPON_RANGE,
        MELEE_TOUCH,
        MELEE_ONE,
        CLOSE_RANGE,
        CLOSE_BURST,
        CLOSE_BLAST,
        RANGED_RANGE,
        RANGED_SIGHT,
        RANGED_WEAPON,
        AREA_BLAST,
        AREA_BURST
    };

    static const int NUM_RANGE_TYPES = 12;
    static const char *RANGE_TYPE_NAMES[];

    enum PowerSource
    {
        DIVINE_POWER,
        MARTIAL_POWER,
        ARCANE_POWER
    };

    static const int NUM_POWER_SOURCES = 3;
    static const char *POWER_SOURCE_NAMES[];

    Power(const XmlPath &path);
    Power(const QString &title);
    Power(const Power &);
    virtual ~Power();
    Power &operator=(const Power &);
    void saveToXml() const;
    void loadFromXml();
    QString description() const;

    XmlPath::BaseTypes base;
    QString baseTypeName;
    int level;
    QString text;
    PowerType type;
    PowerAvailability availability;
    DndData::ClassName associatedClass;
    QString extAssociatedClass;
    QStringList keywords;
    ActionCost actionCost;
    RangeType range;
    QString trigger;
    QString prerequisite;
    QString requirement;
    QString target;
    QString hit;
    QString miss;
    QString detail;
    DndData::Ability ability;
    DndData::DefenceType defence;
    int bonus;
};

QTextStream & operator>>(QTextStream &s, Power::PowerSource &data);
QTextStream & operator>>(QTextStream &s, Power::RangeType &data);
QTextStream & operator>>(QTextStream &s, Power::ActionCost &data);
QTextStream & operator>>(QTextStream &s, Power::PowerAvailability &data);
QTextStream & operator>>(QTextStream &s, Power::PowerType &data);

#endif /* POWER_H_ */
